package com.tgky.ybzb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tgky.ybzb.common.PageParam;
import com.tgky.ybzb.utils.MPUtil;
import com.tgky.ybzb.entity.Zcyrw;
import com.tgky.ybzb.mapper.ZcyrwMapper;
import com.tgky.ybzb.service.IZcyrwService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * 元任务表 服务实现类
 *
 * @author XYP
 * @since 2024-07-22
 */
@Service
public class ZcyrwServiceImpl extends ServiceImpl<ZcyrwMapper, Zcyrw> implements IZcyrwService {

    /**
     * 通过实体类获取QueryWrapper
     * @param pageParam 分页参数
     * @param zcyrw 实体信息
     * @return
     */
    @Override
    public QueryWrapper<Zcyrw> getQueryWrapper(PageParam pageParam, Zcyrw zcyrw){
        QueryWrapper<Zcyrw> queryWrapper = MPUtil.getQueryWrapper(pageParam);

        if(zcyrw == null){
            return queryWrapper;
        }

        //主键
        if(zcyrw.getYrwbh() != null){
            queryWrapper.lambda()
                    .eq(Zcyrw::getYrwbh, zcyrw.getYrwbh());
            return queryWrapper;
        }

        //TODO 此处可以根据各字段查询需求修改查询条件，eq、like、ge、gt、le、lt、ne...等等等
        queryWrapper.lambda()
                .eq(zcyrw.getWxbs() != null, Zcyrw::getWxbs, zcyrw.getWxbs())
                .eq(zcyrw.getCgqbs() != null, Zcyrw::getCgqbs, zcyrw.getCgqbs())
                .eq(zcyrw.getYxj() != null, Zcyrw::getYxj, zcyrw.getYxj())
                .eq(zcyrw.getKssj() != null, Zcyrw::getKssj, zcyrw.getKssj())
                .eq(zcyrw.getJssj() != null, Zcyrw::getJssj, zcyrw.getJssj())
                .eq(zcyrw.getZxdfwsk() != null, Zcyrw::getZxdfwsk, zcyrw.getZxdfwsk())
                .eq(zcyrw.getJd() != null, Zcyrw::getJd, zcyrw.getJd())
                .eq(zcyrw.getWd() != null, Zcyrw::getWd, zcyrw.getWd())
                .eq(zcyrw.getGdqh() != null, Zcyrw::getGdqh, zcyrw.getGdqh())
                .eq(zcyrw.getCbj() != null, Zcyrw::getCbj, zcyrw.getCbj())
                .eq(zcyrw.getTygdj() != null, Zcyrw::getTygdj, zcyrw.getTygdj());
        return queryWrapper;
    }
}
